]> git.r.bdr.sh - rbdr/super-polarity/blobdiff - Super Polarity/ActorFactory.cs
I think bullets come out now.
[rbdr/super-polarity] / Super Polarity / ActorFactory.cs
index 5438b7743d2a65f36ab232048ffc5befa45f91cb..4ebbb4c44afdb96894f89b3f58c498d97621b8c5 100644 (file)
@@ -10,21 +10,60 @@ namespace SuperPolarity
 {
     static class ActorFactory
     {
-        static internal ContentManager Content;
+        static internal Game Game;
 
         static public MainShip CreateMainShip(Vector2 position)
         {
-            MainShip mainShip = new MainShip();
-            mainShip.Initialize(Content, Content.Load<Texture2D>("Graphics\\main-ship"), position);
+            MainShip mainShip = new MainShip(Game);
+            mainShip.Initialize(Game.Content.Load<Texture2D>("Graphics\\main-ship"), position);
 
             ActorManager.CheckIn(mainShip);
 
             return mainShip;
         }
 
-        internal static void SetContentManager(ContentManager content)
+        static public StandardShip CreateShip(Ship.Polarity polarity, Vector2 position)
         {
-            Content = content;
+            StandardShip ship = new StandardShip(Game);
+            Texture2D texture;
+            
+            if (polarity == Ship.Polarity.Positive)
+            {
+                texture = Game.Content.Load<Texture2D>("Graphics\\positive-ship");
+            }
+            else if (polarity == Ship.Polarity.Negative)
+            {
+                texture = Game.Content.Load<Texture2D>("Graphics\\negative-ship");
+            }
+            else
+            {
+                texture = Game.Content.Load<Texture2D>("Graphics\\neutral-ship");
+            }
+
+            ship.Initialize(texture, position);
+            ship.SetPolarity(polarity);
+
+            ActorManager.CheckIn(ship);
+
+            return ship;
+        }
+
+        internal static void SetGame(Game game)
+        {
+            ActorFactory.Game = game;
+        }
+
+        internal static Bullet CreateBullet(Vector2 position, float angle)
+        {
+            Bullet bullet = new Bullet(Game);
+
+            bullet.Initialize(Game.Content.Load<Texture2D>("Graphics\\square"), position);
+
+            bullet.Angle = angle;
+
+            ActorManager.CheckIn(bullet);
+
+            return bullet;
         }
     }
 }